<template>
<span :class="wrapper_name">
  <button v-if="col.btns.ADD_GUIGE" class="ui button primary mini" @click.stop.prevent="add_guige(col.val)" title="添加规格">
    {{col.btns.ADD_GUIGE}}
  </button>
  <!--<button v-if="col.btns.ON" class="ui circular icon button primary mini" @click.stop.prevent="onOff('onOff',1,col.val)" title="上线">-->
    <!--<i class="icon-enable"></i>-->
  <!--</button>-->
  <!--<button v-if="col.btns.OFF" class="ui circular icon button primary mini" @click.stop.prevent="onOff('onOff',0,col.val)" title="下线">-->
    <!--<i class="icon-disable"></i>-->
  <!--</button>-->
  <!--<button v-if="col.btns.OFF" class="ui circular icon button primary mini" @click.stop.prevent="onOff('onOff',-1,col.val)" title="删除">-->
    <!--<i class="icon remove"></i>-->
  <!--</button>-->
</span>
</template>
<script>
  import tool from 'src/util/tool';
  import util from '_util/index';
  import logic from '_logic'
  export default {
    data() {
      return {
      }
    },
    methods: {
        onOff(event, flag = null,id) {
            let confirm = flag == -1 ? logic.list.get_del_msg(this) : '确认此操作吗？';
                util.showConfirm(this, () => {
                    let eventVue = util.store.get(this,'eventVue');
                    eventVue.$emit(event, flag,id)
                }, {content: confirm});
        },
      add_guige(id){
        this.isUnitValid({pid: id}, ()=>{
          this.$router.push(`/page/add?ctl=Product&top_product_id=${id}`);
        })
      },
      isUnitValid(params, cb){
        let url = tool.getApi(this, "Product", "getTypeAttrConf");
        util.http.SR(this, url, params, null,(rs)=>{
          if((rs[2]||[]).length==0){
            util.showMsg(this,'error','尚未配置规格，请在商品类型中添加');
            return;
          };
          this.$store.commit("setProductUnitVo", rs);
          cb();
        });
      }
    },
    computed: {
      ctl(){
        return this.$route.query.ctl;
      },
      is_admin(){
        return util.is_admin(this);
      },
    },
    watch: {
    },

    props: ['col','_id','detail_info','wrapper_name'],
    created() {
    },
  }
</script>
<style rel="stylesheet/less" lang="less"></style>
